﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DDU.Library.Helpers;
using DDU.Library.Attributes;
using System.Reflection;
using System.Windows.Input;
using DDU.Library;
using Microsoft.Phone.Tasks;

namespace DDU.ViewModel
{
    public class AboutAndHelpViewModel : ViewModelBase
    {

#if DESIGN
#else
        Assembly assembly = Assembly.Load("DDU.Curriculum"); 
#endif

        public string Version
        {
            get
            {
                return PhoneHelper.GetAppAttribute("Version");
            }
        }

        public DateTime ReleaseDate
        {
            get
            {
                var date = assembly.GetCustomAttributes(typeof(AssemblyReleaseDateAttribute), false).Cast<AssemblyReleaseDateAttribute>();
                return DateTime.Parse(date.FirstOrDefault().Value);
            }
        }

        public ICommand SendMailCommand
        {
            get
            {
                return new GenericCommand()
                {
                    ExecuteCallback = delegate {
                        EmailComposeTask task = new EmailComposeTask();
                        task.To = AuthorInfo.Email;
                        task.Show();
                    }
                };
            }
        }

        public ICommand OpenRateCommand
        {
            get
            {
                return new GenericCommand()
                {
                    ExecuteCallback = delegate
                    {
                        MarketplaceReviewTask task = new MarketplaceReviewTask();
                        task.Show();
                    }
                };
            }
        }
    }
}
